Thomas Fuß/Gabriel Singer
WS24/25
What you have learned so far:
Ecological datasets have one or both of these datasets (if not more):
Ordination is an umbrella term for multivariate methods which arrange data along a gradient (axis, scale). A sloppy explanation is “putting things in order”.
Ordination is a word almost exclusively used by ecologists. Outside most of these methods are known as scaling techniques. The phrase gradient analysis makes a bit more sense in ecology.
PCA can be understood as a MLR on theoretical (latent) instead of observed dependent variables.
The regression coefficients in PCA are factor loadings.
The predicted values of the theoretical dependent are scores.
For instance, in a PCA on this matrix of n objects times p variables PC1 is computed as:
\[ PC_1=f_1X_1+f_2X_2+...+f_pX_p \] There must be as many PCs as original variables. The factor loading matrix translates p \(X\)-variables into p \(PCs\).
PCA can be understood as a rotation of the original coordinate system made up of p \(X\)-variables into a new coordinate system defined by p \(PCs\).
library(vegan)
## Lade nötiges Paket: permute
## Lade nötiges Paket: lattice
## This is vegan 2.6-4
library(shape) # plots nice arrows
setwd("Z:/COURSES/datenanalyse/vu_datenanalyse/unit_3") #set working directory
mara.raw<-read.table(file="data/MaraRiver.txt",header=TRUE) # water chemistry in 54 streams, 3 types of land use
dim(mara.raw)
## [1] 54 49
head(mara.raw)
## site sampling.time diff.solar.noon landuse order Q canopy Temp cond pH
## 1 Aa20 10:04 145.92 A 2 3.572 0.2 13.4 229.1 7.45
## 2 Aa21 14:01 91.08 A 1 6.600 0.2 17.0 205.4 8.03
## 3 Aa22 16:35 245.08 A 1 1.650 0.3 14.5 205.7 7.88
## 4 Aa23 10:05 145.22 A 1 5.472 0.4 12.1 181.8 7.96
## 5 Aa6b 17:03 270.78 A 2 1.800 0.2 17.5 404.4 7.79
## 6 Af5 14:04 94.38 F 3 4.200 0.4 14.5 129.4 7.94
## turb Alk TSS PO4 NH4 NO2 NO3 Br
## 1 0.02 2160 12.55102 5.16e-07 0.000022800 8.91e-07 0.000054500 2.45e-06
## 2 35.50 2160 59.44444 8.32e-07 0.000023600 6.08e-07 0.000007810 2.06e-06
## 3 0.02 2160 10.57143 1.37e-07 0.000027800 1.13e-06 0.000047300 1.39e-06
## 4 0.02 2160 26.96629 1.00e-06 0.000020700 2.17e-06 0.000124766 1.24e-06
## 5 388.00 3740 209.41176 1.37e-07 0.000446205 1.98e-05 0.000092700 2.47e-06
## 6 28.80 2160 10.21053 1.37e-07 0.000019300 6.95e-07 0.000034900 8.64e-07
## Cl Fl SO4 Na K Ca Mg
## 1 0.000265196 4.47e-05 8.58e-05 0.000930796 0.000423884 0.000328085 0.000152685
## 2 0.000237582 3.91e-05 5.09e-05 0.000843062 0.000323802 0.000323170 0.000146390
## 3 0.000220969 2.87e-05 3.56e-05 0.000622227 0.000373881 0.000372199 0.000157663
## 4 0.000215891 3.03e-05 4.66e-05 0.000716442 0.000299606 0.000300339 0.000132606
## 5 0.000354103 6.12e-05 5.97e-05 0.001070465 0.000989155 0.000507910 0.000253652
## 6 0.000124757 2.87e-05 5.13e-05 NA NA NA NA
## TDN SUVA254 slope slope_short SR_Helms E2.to.E3 E4.to.E6 FIX
## 1 7.82e-05 2.486708 0.01484335 0.01508883 0.8385724 5.729730 7.333333 1.432674
## 2 3.20e-05 2.749288 0.01304546 0.01313918 0.8853058 4.643519 5.000000 1.352617
## 3 7.62e-05 2.957983 0.01374024 0.01376633 0.8516180 4.986425 8.000000 1.371267
## 4 1.48e-04 3.069472 0.01360719 0.01317551 0.8079401 4.892857 6.714286 1.349814
## 5 5.59e-04 1.722983 0.01444961 0.01542405 0.8943684 5.288889 7.833333 1.481364
## 6 5.49e-05 3.088685 0.01376586 0.01382645 0.8333595 4.981043 6.428571 1.336503
## FIX2 HIX beta.alpha X7c_c1 X7c_c2 X7c_c3 X7c_c4
## 1 1.781212 0.8178391 0.7186987 0.002585346 0.5892004 0.4082030 0.2100508
## 2 1.709486 0.7345711 0.6978052 0.075614095 0.7089239 0.4878008 0.2858983
## 3 1.726269 0.7851819 0.6829999 0.037594156 0.8459288 0.5640788 0.3114274
## 4 1.701107 0.8066407 0.6676339 0.010937179 0.6222450 0.4279429 0.2482675
## 5 1.961382 0.6234517 0.7639094 0.222123376 1.8301573 1.7719178 0.5627895
## 6 1.722147 0.8536532 0.6777914 0.035057086 1.3009351 1.0052846 0.5806384
## X7c_c5 X7c_c6 X7c_c7 humF.to.protF humF.per.DOC protF.per.DOC
## 1 0.03701974 0.3347390 0.1175206 9.815030 0.3153769 0.03213204
## 2 0.09037746 0.3795044 0.3062165 3.943447 0.2652603 0.06726611
## 3 0.05079516 0.4395259 0.2434638 6.511800 0.3026556 0.04647802
## 4 0.04149694 0.3223648 0.1405717 8.397779 0.2706781 0.03223210
## 5 0.63429053 1.1599349 1.5369801 2.224790 0.4052359 0.18214567
## 6 0.00000000 0.7400336 0.2134428 14.595144 0.5545706 0.03799693
## DIC.d13C pCO2 EpCO2
## 1 -2.673634 NA NA
## 2 -8.590664 1184.457 3.060612
## 3 -4.565283 1753.501 4.531012
## 4 -7.214370 1094.980 2.829405
## 5 -4.717236 3730.961 9.640726
## 6 -9.946630 NA NA
mara<-mara.raw[,c(4,9:26)] #only select columns of interest
which(is.na(mara), arr.ind=TRUE) #find rows with NAs
## row col
## [1,] 6 15
## [2,] 6 16
## [3,] 6 17
## [4,] 6 18
mara<-mara[-6,] #delete row with NAs
landuse<-mara$landuse
wc<-mara[,-1]
apply(wc, 2, hist) #check normal distribution## $cond
## $breaks
## [1] 50 100 150 200 250 300 350 400 450
##
## $counts
## [1] 29 12 8 3 0 0 0 1
##
## $density
## [1] 0.0109433962 0.0045283019 0.0030188679 0.0011320755 0.0000000000
## [6] 0.0000000000 0.0000000000 0.0003773585
##
## $mids
## [1] 75 125 175 225 275 325 375 425
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $pH
## $breaks
## [1] 7.2 7.4 7.6 7.8 8.0 8.2 8.4 8.6 8.8
##
## $counts
## [1] 3 11 18 13 6 0 1 1
##
## $density
## [1] 0.28301887 1.03773585 1.69811321 1.22641509 0.56603774 0.00000000 0.09433962
## [8] 0.09433962
##
## $mids
## [1] 7.3 7.5 7.7 7.9 8.1 8.3 8.5 8.7
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $turb
## $breaks
## [1] 0 200 400 600 800 1000
##
## $counts
## [1] 50 2 0 0 1
##
## $density
## [1] 4.716981e-03 1.886792e-04 0.000000e+00 0.000000e+00 9.433962e-05
##
## $mids
## [1] 100 300 500 700 900
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Alk
## $breaks
## [1] 0 500 1000 1500 2000 2500 3000 3500 4000
##
## $counts
## [1] 13 25 7 1 6 0 0 1
##
## $density
## [1] 4.905660e-04 9.433962e-04 2.641509e-04 3.773585e-05 2.264151e-04
## [6] 0.000000e+00 0.000000e+00 3.773585e-05
##
## $mids
## [1] 250 750 1250 1750 2250 2750 3250 3750
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $TSS
## $breaks
## [1] 0 50 100 150 200 250
##
## $counts
## [1] 31 18 3 0 1
##
## $density
## [1] 0.0116981132 0.0067924528 0.0011320755 0.0000000000 0.0003773585
##
## $mids
## [1] 25 75 125 175 225
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $PO4
## $breaks
## [1] 0.0e+00 5.0e-07 1.0e-06 1.5e-06 2.0e-06 2.5e-06 3.0e-06
##
## $counts
## [1] 8 15 4 6 18 2
##
## $density
## [1] 301886.8 566037.7 150943.4 226415.1 679245.3 75471.7
##
## $mids
## [1] 2.50e-07 7.50e-07 1.25e-06 1.75e-06 2.25e-06 2.75e-06
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $NH4
## $breaks
## [1] 0.00000 0.00005 0.00010 0.00015 0.00020 0.00025 0.00030 0.00035 0.00040
## [10] 0.00045
##
## $counts
## [1] 51 1 0 0 0 0 0 0 1
##
## $density
## [1] 19245.2830 377.3585 0.0000 0.0000 0.0000 0.0000 0.0000
## [8] 0.0000 377.3585
##
## $mids
## [1] 0.000025 0.000075 0.000125 0.000175 0.000225 0.000275 0.000325 0.000375
## [9] 0.000425
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $NO2
## $breaks
## [1] 0.0e+00 5.0e-06 1.0e-05 1.5e-05 2.0e-05
##
## $counts
## [1] 49 2 1 1
##
## $density
## [1] 184905.660 7547.170 3773.585 3773.585
##
## $mids
## [1] 2.50e-06 7.50e-06 1.25e-05 1.75e-05
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $NO3
## $breaks
## [1] 0.00000 0.00005 0.00010 0.00015 0.00020 0.00025 0.00030 0.00035 0.00040
## [10] 0.00045
##
## $counts
## [1] 21 6 9 6 4 2 2 1 2
##
## $density
## [1] 7924.5283 2264.1509 3396.2264 2264.1509 1509.4340 754.7170 754.7170
## [8] 377.3585 754.7170
##
## $mids
## [1] 0.000025 0.000075 0.000125 0.000175 0.000225 0.000275 0.000325 0.000375
## [9] 0.000425
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Br
## $breaks
## [1] 0.0e+00 5.0e-07 1.0e-06 1.5e-06 2.0e-06 2.5e-06
##
## $counts
## [1] 18 22 10 0 3
##
## $density
## [1] 679245.3 830188.7 377358.5 0.0 113207.5
##
## $mids
## [1] 2.50e-07 7.50e-07 1.25e-06 1.75e-06 2.25e-06
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Cl
## $breaks
## [1] 0.00000 0.00005 0.00010 0.00015 0.00020 0.00025 0.00030 0.00035 0.00040
##
## $counts
## [1] 5 19 17 4 6 1 0 1
##
## $density
## [1] 1886.7925 7169.8113 6415.0943 1509.4340 2264.1509 377.3585 0.0000
## [8] 377.3585
##
## $mids
## [1] 0.000025 0.000075 0.000125 0.000175 0.000225 0.000275 0.000325 0.000375
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Fl
## $breaks
## [1] 1e-05 2e-05 3e-05 4e-05 5e-05 6e-05 7e-05
##
## $counts
## [1] 10 28 8 4 1 2
##
## $density
## [1] 18867.925 52830.189 15094.340 7547.170 1886.792 3773.585
##
## $mids
## [1] 1.5e-05 2.5e-05 3.5e-05 4.5e-05 5.5e-05 6.5e-05
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $SO4
## $breaks
## [1] 0e+00 1e-05 2e-05 3e-05 4e-05 5e-05 6e-05 7e-05 8e-05 9e-05
##
## $counts
## [1] 3 34 9 3 1 2 0 0 1
##
## $density
## [1] 5660.377 64150.943 16981.132 5660.377 1886.792 3773.585 0.000
## [8] 0.000 1886.792
##
## $mids
## [1] 5.0e-06 1.5e-05 2.5e-05 3.5e-05 4.5e-05 5.5e-05 6.5e-05 7.5e-05 8.5e-05
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Na
## $breaks
## [1] 0.0000 0.0002 0.0004 0.0006 0.0008 0.0010 0.0012
##
## $counts
## [1] 2 23 17 5 4 2
##
## $density
## [1] 188.6792 2169.8113 1603.7736 471.6981 377.3585 188.6792
##
## $mids
## [1] 0.0001 0.0003 0.0005 0.0007 0.0009 0.0011
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $K
## $breaks
## [1] 0e+00 2e-04 4e-04 6e-04 8e-04 1e-03
##
## $counts
## [1] 39 12 1 0 1
##
## $density
## [1] 3679.24528 1132.07547 94.33962 0.00000 94.33962
##
## $mids
## [1] 1e-04 3e-04 5e-04 7e-04 9e-04
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Ca
## $breaks
## [1] 0.00000 0.00005 0.00010 0.00015 0.00020 0.00025 0.00030 0.00035 0.00040
## [10] 0.00045 0.00050 0.00055
##
## $counts
## [1] 2 23 17 6 0 0 3 1 0 0 1
##
## $density
## [1] 754.7170 8679.2453 6415.0943 2264.1509 0.0000 0.0000 1132.0755
## [8] 377.3585 0.0000 0.0000 377.3585
##
## $mids
## [1] 0.000025 0.000075 0.000125 0.000175 0.000225 0.000275 0.000325 0.000375
## [9] 0.000425 0.000475 0.000525
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Mg
## $breaks
## [1] 0.00000 0.00005 0.00010 0.00015 0.00020 0.00025 0.00030
##
## $counts
## [1] 28 20 2 2 0 1
##
## $density
## [1] 10566.0377 7547.1698 754.7170 754.7170 0.0000 377.3585
##
## $mids
## [1] 0.000025 0.000075 0.000125 0.000175 0.000225 0.000275
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $TDN
## $breaks
## [1] 0e+00 1e-04 2e-04 3e-04 4e-04 5e-04 6e-04
##
## $counts
## [1] 26 11 9 4 2 1
##
## $density
## [1] 4905.6604 2075.4717 1698.1132 754.7170 377.3585 188.6792
##
## $mids
## [1] 0.00005 0.00015 0.00025 0.00035 0.00045 0.00055
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
wc[,-2]<-log(wc[,-2]) #log-transform concentration data (not pH)
apply(wc, 2, hist) #check normal distribution
## $cond
## $breaks
## [1] 3.5 4.0 4.5 5.0 5.5 6.0 6.5
##
## $counts
## [1] 4 20 17 11 0 1
##
## $density
## [1] 0.15094340 0.75471698 0.64150943 0.41509434 0.00000000 0.03773585
##
## $mids
## [1] 3.75 4.25 4.75 5.25 5.75 6.25
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $pH
## $breaks
## [1] 7.2 7.4 7.6 7.8 8.0 8.2 8.4 8.6 8.8
##
## $counts
## [1] 3 11 18 13 6 0 1 1
##
## $density
## [1] 0.28301887 1.03773585 1.69811321 1.22641509 0.56603774 0.00000000 0.09433962
## [8] 0.09433962
##
## $mids
## [1] 7.3 7.5 7.7 7.9 8.1 8.3 8.5 8.7
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $turb
## $breaks
## [1] -4 -2 0 2 4 6 8
##
## $counts
## [1] 21 1 3 14 13 1
##
## $density
## [1] 0.198113208 0.009433962 0.028301887 0.132075472 0.122641509 0.009433962
##
## $mids
## [1] -3 -1 1 3 5 7
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Alk
## $breaks
## [1] 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5
##
## $counts
## [1] 1 1 24 14 6 6 1
##
## $density
## [1] 0.03773585 0.03773585 0.90566038 0.52830189 0.22641509 0.22641509 0.03773585
##
## $mids
## [1] 5.25 5.75 6.25 6.75 7.25 7.75 8.25
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $TSS
## $breaks
## [1] 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
##
## $counts
## [1] 1 6 11 7 10 14 3 1
##
## $density
## [1] 0.03773585 0.22641509 0.41509434 0.26415094 0.37735849 0.52830189 0.11320755
## [8] 0.03773585
##
## $mids
## [1] 1.75 2.25 2.75 3.25 3.75 4.25 4.75 5.25
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $PO4
## $breaks
## [1] -16.0 -15.5 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5
##
## $counts
## [1] 5 1 2 10 8 18 9
##
## $density
## [1] 0.18867925 0.03773585 0.07547170 0.37735849 0.30188679 0.67924528 0.33962264
##
## $mids
## [1] -15.75 -15.25 -14.75 -14.25 -13.75 -13.25 -12.75
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $NH4
## $breaks
## [1] -15 -14 -13 -12 -11 -10 -9 -8 -7
##
## $counts
## [1] 2 0 4 19 25 2 0 1
##
## $density
## [1] 0.03773585 0.00000000 0.07547170 0.35849057 0.47169811 0.03773585 0.00000000
## [8] 0.01886792
##
## $mids
## [1] -14.5 -13.5 -12.5 -11.5 -10.5 -9.5 -8.5 -7.5
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $NO2
## $breaks
## [1] -16 -15 -14 -13 -12 -11 -10
##
## $counts
## [1] 4 17 24 4 3 1
##
## $density
## [1] 0.07547170 0.32075472 0.45283019 0.07547170 0.05660377 0.01886792
##
## $mids
## [1] -15.5 -14.5 -13.5 -12.5 -11.5 -10.5
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $NO3
## $breaks
## [1] -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5
##
## $counts
## [1] 1 0 2 0 11 6 6 2 15 7 3
##
## $density
## [1] 0.03773585 0.00000000 0.07547170 0.00000000 0.41509434 0.22641509
## [7] 0.22641509 0.07547170 0.56603774 0.26415094 0.11320755
##
## $mids
## [1] -12.75 -12.25 -11.75 -11.25 -10.75 -10.25 -9.75 -9.25 -8.75 -8.25
## [11] -7.75
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Br
## $breaks
## [1] -16.0 -15.5 -15.0 -14.5 -14.0 -13.5 -13.0 -12.5
##
## $counts
## [1] 2 6 10 16 14 3 2
##
## $density
## [1] 0.0754717 0.2264151 0.3773585 0.6037736 0.5283019 0.1132075 0.0754717
##
## $mids
## [1] -15.75 -15.25 -14.75 -14.25 -13.75 -13.25 -12.75
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Cl
## $breaks
## [1] -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5
##
## $counts
## [1] 1 0 0 0 4 8 23 10 6 1
##
## $density
## [1] 0.03773585 0.00000000 0.00000000 0.00000000 0.15094340 0.30188679
## [7] 0.86792453 0.37735849 0.22641509 0.03773585
##
## $mids
## [1] -12.25 -11.75 -11.25 -10.75 -10.25 -9.75 -9.25 -8.75 -8.25 -7.75
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Fl
## $breaks
## [1] -11.6 -11.4 -11.2 -11.0 -10.8 -10.6 -10.4 -10.2 -10.0 -9.8 -9.6
##
## $counts
## [1] 1 2 2 8 12 14 3 7 2 2
##
## $density
## [1] 0.09433962 0.18867925 0.18867925 0.75471698 1.13207547 1.32075472
## [7] 0.28301887 0.66037736 0.18867925 0.18867925
##
## $mids
## [1] -11.5 -11.3 -11.1 -10.9 -10.7 -10.5 -10.3 -10.1 -9.9 -9.7
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $SO4
## $breaks
## [1] -13.0 -12.5 -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0
##
## $counts
## [1] 3 0 0 21 22 3 3 1
##
## $density
## [1] 0.11320755 0.00000000 0.00000000 0.79245283 0.83018868 0.11320755 0.11320755
## [8] 0.03773585
##
## $mids
## [1] -12.75 -12.25 -11.75 -11.25 -10.75 -10.25 -9.75 -9.25
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Na
## $breaks
## [1] -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0 -6.5
##
## $counts
## [1] 1 0 1 17 21 9 4
##
## $density
## [1] 0.03773585 0.00000000 0.03773585 0.64150943 0.79245283 0.33962264 0.15094340
##
## $mids
## [1] -9.75 -9.25 -8.75 -8.25 -7.75 -7.25 -6.75
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $K
## $breaks
## [1] -12 -11 -10 -9 -8 -7 -6
##
## $counts
## [1] 1 0 12 36 3 1
##
## $density
## [1] 0.01886792 0.00000000 0.22641509 0.67924528 0.05660377 0.01886792
##
## $mids
## [1] -11.5 -10.5 -9.5 -8.5 -7.5 -6.5
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Ca
## $breaks
## [1] -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5
##
## $counts
## [1] 1 0 12 23 12 3 2
##
## $density
## [1] 0.03773585 0.00000000 0.45283019 0.86792453 0.45283019 0.11320755 0.07547170
##
## $mids
## [1] -10.75 -10.25 -9.75 -9.25 -8.75 -8.25 -7.75
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $Mg
## $breaks
## [1] -12.0 -11.5 -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0
##
## $counts
## [1] 1 0 1 21 22 3 4 1
##
## $density
## [1] 0.03773585 0.00000000 0.03773585 0.79245283 0.83018868 0.11320755 0.15094340
## [8] 0.03773585
##
## $mids
## [1] -11.75 -11.25 -10.75 -10.25 -9.75 -9.25 -8.75 -8.25
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
##
## $TDN
## $breaks
## [1] -11.0 -10.5 -10.0 -9.5 -9.0 -8.5 -8.0 -7.5 -7.0
##
## $counts
## [1] 3 13 6 5 10 11 4 1
##
## $density
## [1] 0.11320755 0.49056604 0.22641509 0.18867925 0.37735849 0.41509434 0.15094340
## [8] 0.03773585
##
## $mids
## [1] -10.75 -10.25 -9.75 -9.25 -8.75 -8.25 -7.75 -7.25
##
## $xname
## [1] "newX[, i]"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
plot(wc) # check potential for PCA by correlation plot
pca<-prcomp(scale(wc),center=F,scale.=F)
pca<-prcomp(wc,center=T,scale.=T) # equivalent to line above
summary(pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 2.8392 1.8644 1.22808 1.10689 0.84577 0.80664 0.78730
## Proportion of Variance 0.4478 0.1931 0.08379 0.06807 0.03974 0.03615 0.03444
## Cumulative Proportion 0.4478 0.6410 0.72474 0.79281 0.83255 0.86870 0.90314
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.66233 0.6392 0.53771 0.40863 0.3445 0.32772 0.29622
## Proportion of Variance 0.02437 0.0227 0.01606 0.00928 0.0066 0.00597 0.00487
## Cumulative Proportion 0.92751 0.9502 0.96627 0.97554 0.9821 0.98810 0.99298
## PC15 PC16 PC17 PC18
## Standard deviation 0.25252 0.21425 0.1038 0.07711
## Proportion of Variance 0.00354 0.00255 0.0006 0.00033
## Cumulative Proportion 0.99652 0.99907 0.9997 1.00000
pca$sdev # stdevs of PCs (squares are eigenvalues); eigenvalues correspond to the variance of their respective principal component (PC)
## [1] 2.83921334 1.86442507 1.22808376 1.10689311 0.84576999 0.80663510
## [7] 0.78729929 0.66233089 0.63915683 0.53770934 0.40862593 0.34454651
## [13] 0.32772103 0.29622209 0.25251770 0.21424557 0.10379779 0.07711088
eigenvals(pca)==pca$sdev^2
## PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11 PC12 PC13 PC14 PC15 PC16
## TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## PC17 PC18
## TRUE TRUE
head(scores<-pca$x) # site scores on all PCs
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## 1 -4.749326 3.557587 0.52830345 1.6885404 0.4637009 0.6815660 0.06534355
## 2 -3.830547 3.155164 0.07572526 -2.0332541 0.2644377 1.1129832 -0.55448962
## 3 -3.267373 4.108748 -0.32897368 0.7711051 -1.0759520 -0.2527134 0.44879703
## 4 -3.680797 2.292490 0.80951314 0.2051344 -0.2780356 -0.6345223 0.05431164
## 5 -8.999719 1.602003 -3.03923365 -1.2132318 -1.0636252 -1.2871947 0.42462524
## 7 2.315295 1.447056 0.53769126 0.3896117 0.5148749 -1.6163461 -0.06189673
## PC8 PC9 PC10 PC11 PC12 PC13
## 1 0.9056796 -0.1326339 -0.36156648 0.3464919 -0.343851835 -0.09665447
## 2 1.2660092 -0.0486270 -1.04265251 -0.2685484 -0.237503649 -0.68256243
## 3 -0.1695538 -0.4501332 -0.45996058 0.5662810 0.124965534 -0.53160488
## 4 -0.5018929 -0.9758938 -0.49191459 0.1223105 -0.230524069 0.50704177
## 5 0.3163298 -0.1965387 -0.05913828 -0.1130011 1.000404068 0.11682215
## 7 -1.1804198 -1.0651942 -0.46082573 -1.2090894 -0.008212293 -0.32546687
## PC14 PC15 PC16 PC17 PC18
## 1 0.36104029 0.1178840 0.004293307 0.04989172 0.05965282
## 2 -0.14602705 -0.1922231 0.155271851 0.28350624 -0.09569322
## 3 -0.40743689 0.4087700 0.288081091 -0.24071374 0.04519902
## 4 -0.01593147 -0.3959628 -0.098755194 -0.01316164 0.08656537
## 5 -0.17548689 0.1746190 -0.311008889 0.19590434 -0.02083158
## 7 0.58480671 -0.4687339 -0.016056662 -0.03962186 0.01500699
head(scale(wc) %*% pca$rotation) # to manually compute scores from variables and loadings
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## 1 -4.749326 3.557587 0.52830345 1.6885404 0.4637009 0.6815660 0.06534355
## 2 -3.830547 3.155164 0.07572526 -2.0332541 0.2644377 1.1129832 -0.55448962
## 3 -3.267373 4.108748 -0.32897368 0.7711051 -1.0759520 -0.2527134 0.44879703
## 4 -3.680797 2.292490 0.80951314 0.2051344 -0.2780356 -0.6345223 0.05431164
## 5 -8.999719 1.602003 -3.03923365 -1.2132318 -1.0636252 -1.2871947 0.42462524
## 7 2.315295 1.447056 0.53769126 0.3896117 0.5148749 -1.6163461 -0.06189673
## PC8 PC9 PC10 PC11 PC12 PC13
## 1 0.9056796 -0.1326339 -0.36156648 0.3464919 -0.343851835 -0.09665447
## 2 1.2660092 -0.0486270 -1.04265251 -0.2685484 -0.237503649 -0.68256243
## 3 -0.1695538 -0.4501332 -0.45996058 0.5662810 0.124965534 -0.53160488
## 4 -0.5018929 -0.9758938 -0.49191459 0.1223105 -0.230524069 0.50704177
## 5 0.3163298 -0.1965387 -0.05913828 -0.1130011 1.000404068 0.11682215
## 7 -1.1804198 -1.0651942 -0.46082573 -1.2090894 -0.008212293 -0.32546687
## PC14 PC15 PC16 PC17 PC18
## 1 0.36104029 0.1178840 0.004293307 0.04989172 0.05965282
## 2 -0.14602705 -0.1922231 0.155271851 0.28350624 -0.09569322
## 3 -0.40743689 0.4087700 0.288081091 -0.24071374 0.04519902
## 4 -0.01593147 -0.3959628 -0.098755194 -0.01316164 0.08656537
## 5 -0.17548689 0.1746190 -0.311008889 0.19590434 -0.02083158
## 7 0.58480671 -0.4687339 -0.016056662 -0.03962186 0.01500699
head(loadings<-pca$rotation) # the variable loadings
## PC1 PC2 PC3 PC4 PC5 PC6
## cond -0.26935347 0.1438792 -0.2841620 -0.03056776 0.12191093 0.08071683
## pH 0.04777530 0.1215468 0.3562802 -0.59539396 -0.49268822 -0.29216145
## turb -0.14155181 -0.3894707 -0.2177088 -0.32746528 -0.03611414 0.24629283
## Alk -0.17098754 0.3503345 -0.1962747 0.09297582 0.10935101 -0.12209184
## TSS -0.14508786 -0.3207217 -0.2732119 -0.44573924 -0.03791156 0.26821922
## PO4 -0.01446834 -0.2443586 0.4595895 -0.23241378 0.72222431 -0.10638692
## PC7 PC8 PC9 PC10 PC11 PC12
## cond -0.41973560 -0.17562478 -0.09881877 -0.006566902 0.64824153 -0.064479508
## pH -0.22576487 -0.26192817 0.06281913 -0.192775926 0.05253252 -0.003739136
## turb -0.04788218 0.07002402 -0.01614397 0.011308932 -0.32201794 -0.137669971
## Alk -0.42805174 -0.15744036 -0.37748332 -0.112749767 -0.59639437 0.187029632
## TSS 0.02529992 0.16003510 -0.08747407 -0.150755304 -0.03128159 0.262605089
## PO4 -0.05401838 -0.17326809 -0.05875984 -0.015299767 -0.07294578 -0.177318022
## PC13 PC14 PC15 PC16 PC17
## cond -0.12739932 0.02559159 -0.11856620 -0.336469042 -0.0003470607
## pH -0.04129351 0.07363790 0.02360840 0.043866907 -0.0064374198
## turb -0.59531621 -0.04723956 0.24918988 -0.223721709 -0.1124305273
## Alk 0.01598820 0.05220398 -0.07854688 0.058152265 0.0221005482
## TSS 0.55485685 -0.08756056 -0.29311696 0.002605816 0.0204648859
## PO4 0.03082657 0.13171082 -0.19384168 -0.090576799 0.0664719576
## PC18
## cond 0.135379479
## pH 0.017462207
## turb 0.005186753
## Alk 0.084188983
## TSS 0.030558062
## PO4 -0.005485131
# how many axes should be kept?
#there is not the one well-accepted method
#1. visual examination
#looking for a point at which the proportion of variance explained by each subsequent principal component drops off (elbow of scree plot)
screeplot(pca, npcs=length(pca$sdev), type = "lines") # plots eigenvalues vs. principal components (PCs) #
#2 Kaiser-Guttman criterion
# retain PCs with eigenvalues>1, PCs with eigenvalues<1 contain less informatin than one original variable
abline(h=1,col="red")# eigenvalue of PC5<1
#3. variance explained method: set an "arbitrary" threshold of explained variance (e.g. 70%, 80%, 90%) and choose as many PCs till threshold is reached.
summary(pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 2.8392 1.8644 1.22808 1.10689 0.84577 0.80664 0.78730
## Proportion of Variance 0.4478 0.1931 0.08379 0.06807 0.03974 0.03615 0.03444
## Cumulative Proportion 0.4478 0.6410 0.72474 0.79281 0.83255 0.86870 0.90314
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.66233 0.6392 0.53771 0.40863 0.3445 0.32772 0.29622
## Proportion of Variance 0.02437 0.0227 0.01606 0.00928 0.0066 0.00597 0.00487
## Cumulative Proportion 0.92751 0.9502 0.96627 0.97554 0.9821 0.98810 0.99298
## PC15 PC16 PC17 PC18
## Standard deviation 0.25252 0.21425 0.1038 0.07711
## Proportion of Variance 0.00354 0.00255 0.0006 0.00033
## Cumulative Proportion 0.99652 0.99907 0.9997 1.00000
# -> the first 3-4 PCs seem useful, and just PC1 and PC2 alone are already explaining a lot of overall variance
# for a DISTANCE BIPLOT (focus is on sites, "scaling 1")
# each principal component has variance given by eigenvalue, loadings remain unscaled
str(landuse)
## chr [1:53] "A" "A" "A" "A" "A" "M" "F" "M" "M" "M" "F" "A" "A" "A" "A" "A" ...
landuse<-as.factor(landuse)
plot(scores[,1:2],asp=1,pch=21, cex=2, bg=landuse) # note asp=1
arrows<-loadings*15 # with extension factor
Arrows(x0=0,y0=0,x1=arrows[,1],y1=arrows[,2],col="darkgreen")
text(x=arrows[,1]*1.2,y=arrows[,2]*1.2,labels=names(wc),cex=0.8)
#text(scores[,1:2], rownames(wc), pos=2)
legend("bottomright", legend=c("Agriculture", "Mixed", "Forest"), pch=21, pt.cex=2, pt.bg=c("black","green","darkred"), cex=1.5)# in this plot:
# 1) distances among sites are approximating true Euclidean distances in multivariate space
# 2) angles between arrows do not reflect correlations among variables
# 3) projecting site on descriptor at right angle gives its appr. descriptor value
# for a CORRELATION BIPLOT (focus is on variables, "scaling 2")
# each principal component is weighted by 1/sqrt(eigenvalue), so it has variance 1
var(scores[,1]/pca$sdev[1]) # just demo
## [1] 1
plot(scores[,1]/pca$sdev[1],scores[,2]/pca$sdev[2],pch=21,bg=landuse,asp=1)
# loadings are weighted by sqrt(eigenvalues)
arrows<-loadings*matrix(pca$sdev,nrow=nrow(loadings),ncol=ncol(loadings),byrow=TRUE)
arrows<-arrows*2 # choose extension factor
Arrows(x0=0,y0=0,x1=arrows[,1],y1=arrows[,2],col="purple")
# as alternative just compute correlation of scores with original data ("structure coefficients")
(structure<-cor(wc,scores))
## PC1 PC2 PC3 PC4 PC5 PC6
## cond -0.76475195 0.26825195 -0.34897469 -0.03383524 0.103108608 0.065109031
## pH 0.13564426 0.22661496 0.43754197 -0.65903747 -0.416700907 -0.235667684
## turb -0.40189578 -0.72613887 -0.26736468 -0.36246906 -0.030544259 0.198668445
## Alk -0.48547011 0.65317251 -0.24104174 0.10291430 0.092485802 -0.098483565
## TSS -0.41193538 -0.59796155 -0.33552705 -0.49338569 -0.032064459 0.216355039
## PO4 -0.04107869 -0.45558830 0.56441437 -0.25725721 0.610835646 -0.085815422
## NH4 -0.59306916 0.02901967 -0.52211239 -0.05077205 0.146005150 -0.407246534
## NO2 -0.60159868 -0.44979709 -0.11708309 -0.06542819 -0.083433731 -0.478631077
## NO3 -0.51894312 -0.68971906 0.17118492 0.35407824 -0.145546662 -0.008334060
## Br -0.92514493 -0.10433460 0.06301001 0.05315603 0.008796639 0.221187748
## Cl -0.82983473 -0.12663016 0.38234130 0.16849740 0.028517422 -0.093976441
## Fl -0.85617616 -0.08722719 0.14001888 -0.03859390 0.108893567 -0.027198849
## SO4 -0.81130553 0.18629947 0.30840708 0.17786031 -0.164712321 0.009860507
## Na -0.88109521 0.13206079 0.10468309 0.04519175 -0.161228683 0.142295300
## K -0.79637284 0.37181544 0.19278724 -0.11851266 0.026616893 0.075563024
## Ca -0.73330911 0.56721172 -0.04684159 -0.17535185 0.084387922 0.046307940
## Mg -0.76241145 0.49212149 0.03837621 -0.19104400 0.036005859 0.052768803
## TDN -0.66409999 -0.60500271 -0.04421175 0.24134387 -0.151522130 -0.055259365
## PC7 PC8 PC9 PC10 PC11
## cond -0.33045754 -0.11632172 -0.063160692 -0.003531084 0.264888300
## pH -0.17774452 -0.17348312 0.040151278 -0.103657416 0.021466149
## turb -0.03769761 0.04637907 -0.010318528 0.006080919 -0.131584882
## Alk -0.33700483 -0.10427761 -0.241271045 -0.060626603 -0.243702206
## TSS 0.01991861 0.10599619 -0.055909646 -0.081062536 -0.012782470
## PO4 -0.04252863 -0.11476081 -0.037556751 -0.008226828 -0.029807536
## NH4 0.14949569 -0.04291440 0.365863964 -0.155284000 -0.033708442
## NO2 0.07756756 0.19275231 -0.298888832 0.209087387 0.052794089
## NO3 0.01371875 -0.25604120 -0.048509024 -0.033794332 -0.013701263
## Br 0.04173239 0.00127664 -0.052263599 -0.162136464 0.069169573
## Cl -0.03699389 0.13621525 0.008198462 -0.180611063 0.032692795
## Fl -0.33251999 0.16703916 0.191260615 0.124728010 0.003445899
## SO4 0.05600956 0.30157467 -0.015244843 -0.159709162 -0.046927081
## Na -0.13133773 -0.01459469 0.187683610 0.211586965 -0.073979848
## K 0.21133725 -0.08141740 0.106111667 0.223653004 -0.011006163
## Ca 0.21377568 -0.09313882 -0.149458288 -0.054964294 0.017660115
## Mg 0.32651015 -0.06474423 -0.077876661 0.034731711 -0.011551626
## TDN 0.04747067 -0.30977212 -0.004718641 0.007756368 -0.019322840
## PC12 PC13 PC14 PC15 PC16
## cond -0.022216190 -0.041751438 0.0075807958 -0.029940066 -0.0720870031
## pH -0.001288306 -0.013532752 0.0218131727 0.005961538 0.0093982907
## turb -0.047433709 -0.195097641 -0.0139934007 0.062924857 -0.0479313860
## Alk 0.064440408 0.005239670 0.0154639711 -0.019834478 0.0124588654
## TSS 0.090479668 0.181838259 -0.0259373713 -0.074017223 0.0005582845
## PO4 -0.061094306 0.010102514 0.0390156553 -0.048948456 -0.0194056782
## NH4 -0.019558805 -0.008153826 0.0261212836 -0.022615617 0.0068037616
## NO2 -0.018137139 -0.022027853 0.0217333801 -0.022298082 0.0303642603
## NO3 -0.015197048 0.066748065 0.0090589510 0.018038656 -0.0081950848
## Br 0.003987132 -0.074486267 0.1268513291 -0.005079333 0.1418328916
## Cl 0.108916049 -0.077892719 -0.1965043400 -0.029094888 0.0066897381
## Fl 0.021179746 0.098884906 0.0044583717 0.154701308 0.0292928111
## SO4 -0.064893733 0.034208880 0.1163038494 -0.018049823 -0.1085844000
## Na -0.153097268 0.003712544 -0.0563765190 -0.126996360 0.0355530451
## K 0.216803483 -0.052579706 0.0705418244 -0.028508949 -0.0372784074
## Ca -0.081684815 0.049612428 -0.0519750553 0.054216175 -0.0041896038
## Mg -0.068998656 0.024034873 -0.0651154780 0.058400432 0.0043412431
## TDN 0.023214045 0.028784640 -0.0001785383 0.029159768 -0.0353732943
## PC17 PC18
## cond -3.602414e-05 0.0104392312
## pH -6.681899e-04 0.0013465262
## turb -1.167004e-02 0.0003999551
## Alk 2.293988e-03 0.0064918868
## TSS 2.124210e-03 0.0023563591
## PO4 6.899642e-03 -0.0004229633
## NH4 -9.032968e-03 0.0036488485
## NO2 -2.342515e-03 -0.0016575665
## NO3 -6.145284e-02 0.0262899055
## Br 8.706134e-03 -0.0017381812
## Cl 6.151965e-04 -0.0017187344
## Fl 6.209194e-04 -0.0016118828
## SO4 6.993261e-03 -0.0001298039
## Na -2.090597e-04 -0.0059058664
## K -1.630078e-02 -0.0026053297
## Ca -3.672943e-02 -0.0461913573
## Mg 3.246239e-02 0.0471881766
## TDN 6.262864e-02 -0.0258731171
structure<-2*structure
Arrows(x0=0,y0=0,x1=structure[,1],y1=structure[,2],col="red")
text(x=arrows[,1]*1.3,y=arrows[,2]*1.2,labels=names(wc),cex=0.7)# in this plot
# 1) distances among sites are not approximating true Euclidean distances in multivariate space
# 2) angles between arrows reflect correlations among variables (NOT proximity of arrow heads)
# 3) projecting site on descriptor at right angle gives its appr. descriptor value
# PCA using the rda function from the vegan package
pca2<-rda(X=wc,scale=TRUE)
summary(pca2,scaling=1)
##
## Call:
## rda(X = wc, scale = TRUE)
##
## Partitioning of correlations:
## Inertia Proportion
## Total 18 1
## Unconstrained 18 1
##
## Eigenvalues, and their contribution to the correlations
##
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Eigenvalue 8.0611 3.4761 1.50819 1.22521 0.71533 0.65066 0.61984
## Proportion Explained 0.4478 0.1931 0.08379 0.06807 0.03974 0.03615 0.03444
## Cumulative Proportion 0.4478 0.6410 0.72474 0.79281 0.83255 0.86870 0.90314
## PC8 PC9 PC10 PC11 PC12 PC13
## Eigenvalue 0.43868 0.4085 0.28913 0.166975 0.118712 0.107401
## Proportion Explained 0.02437 0.0227 0.01606 0.009276 0.006595 0.005967
## Cumulative Proportion 0.92751 0.9502 0.96627 0.975542 0.982137 0.988104
## PC14 PC15 PC16 PC17 PC18
## Eigenvalue 0.087748 0.063765 0.04590 0.0107740 0.0059461
## Proportion Explained 0.004875 0.003543 0.00255 0.0005986 0.0003303
## Cumulative Proportion 0.992979 0.996521 0.99907 0.9996697 1.0000000
##
## Scaling 1 for species and site scores
## * Sites are scaled proportional to eigenvalues
## * Species are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores: 5.531195
##
##
## Species scores
##
## PC1 PC2 PC3 PC4 PC5 PC6
## cond -1.48985 0.79582 -1.5718 -0.1691 0.67431 0.44646
## pH 0.26425 0.67230 1.9707 -3.2932 -2.72515 -1.61600
## turb -0.78295 -2.15424 -1.2042 -1.8113 -0.19975 1.36229
## Alk -0.94577 1.93777 -1.0856 0.5143 0.60484 -0.67531
## TSS -0.80251 -1.77397 -1.5112 -2.4655 -0.20970 1.48357
## PO4 -0.08003 -1.35160 2.5421 -1.2855 3.99476 -0.58845
## NH4 -1.15538 0.08609 -2.3516 -0.2537 0.95485 -2.79254
## NO2 -1.17200 -1.33441 -0.5273 -0.3269 -0.54564 -3.28203
## NO3 -1.01098 -2.04619 0.7710 1.7693 -0.95185 -0.05715
## Br -1.80232 -0.30953 0.2838 0.2656 0.05753 1.51671
## Cl -1.61664 -0.37567 1.7220 0.8420 0.18650 -0.64441
## Fl -1.66795 -0.25878 0.6306 -0.1929 0.71215 -0.18651
## SO4 -1.58054 0.55270 1.3890 0.8888 -1.07719 0.06761
## Na -1.71650 0.39179 0.4715 0.2258 -1.05441 0.97574
## K -1.55145 1.10307 0.8683 -0.5922 0.17407 0.51814
## Ca -1.42859 1.68275 -0.2110 -0.8762 0.55188 0.31754
## Mg -1.48529 1.45998 0.1728 -0.9547 0.23547 0.36184
## TDN -1.29376 -1.79486 -0.1991 1.2060 -0.99093 -0.37892
##
##
## Site scores (weighted sums of species scores)
##
## PC1 PC2 PC3 PC4 PC5 PC6
## 1 -0.858644 0.64319 0.095513 0.30528 0.083834 0.123222
## 2 -0.692535 0.57043 0.013691 -0.36760 0.047808 0.201219
## 3 -0.590717 0.74283 -0.059476 0.13941 -0.194524 -0.045689
## 4 -0.665461 0.41447 0.146354 0.03709 -0.050267 -0.114717
## 5 -1.627084 0.28963 -0.549471 -0.21934 -0.192296 -0.232715
## 7 0.418588 0.26162 0.097211 0.07044 0.093086 -0.292224
## 8 0.990156 0.31409 -0.773129 -0.34073 -0.067209 0.150470
## 9 -0.298376 0.20548 -0.191656 0.70420 -0.194790 0.113638
## 10 -0.509697 0.18895 0.022804 -0.32743 0.211013 0.044924
## 11 0.158309 0.31689 -0.173319 0.16996 0.237407 0.066935
## 12 0.764213 0.20918 -0.027062 0.06540 -0.147885 -0.096221
## 13 -0.178540 -0.35882 -0.150284 -0.02218 0.196198 0.030318
## 14 1.242212 -0.56161 -0.617922 0.08199 0.106896 -0.193683
## 15 -0.368970 -0.58101 -0.007750 -0.05095 -0.062378 0.057150
## 16 -0.669563 -0.04282 -0.047768 0.21397 0.152919 -0.277781
## 17 -0.761438 -0.24526 0.029662 0.03186 0.056651 -0.066478
## 18 -0.425436 -0.04832 -0.024151 0.02310 0.017175 0.226641
## 19 -0.234255 -0.27163 0.068958 -0.19446 -0.054914 0.018765
## 20 0.028982 -0.19608 -0.178394 0.05594 -0.199762 0.196180
## 21 -0.338971 -0.32675 0.150791 -0.08567 -0.105597 -0.022958
## 22 -0.128236 -0.32483 0.196796 -0.01866 -0.024355 0.385547
## 23 -0.363328 -0.18509 0.059418 -0.09107 0.017646 -0.048482
## 24 -0.596633 -0.45527 0.025255 -0.01668 0.055688 -0.127478
## 25 -0.030951 -0.36593 0.256660 -0.43481 -0.257818 -0.221803
## 26 0.192175 -0.44357 0.021972 -0.10034 0.052713 0.006413
## 27 0.041707 -0.25523 -0.121742 0.14506 -0.148207 0.038812
## 28 0.076520 -0.45121 -0.037076 -0.03006 0.096141 -0.035485
## 29 0.088275 -0.39706 0.026841 0.03825 0.115360 0.051904
## 30 -0.162040 -0.39082 -0.260650 0.12857 -0.041694 0.066871
## 31 0.400213 0.29276 0.183117 0.16617 -0.022077 0.210915
## 32 0.194940 0.27892 0.011061 0.10721 0.008114 -0.041581
## 33 0.096061 -0.04411 0.261267 0.44553 -0.062379 -0.335050
## 34 -0.082955 0.21771 0.144274 -0.37113 0.087125 -0.031603
## 35 -0.004696 -0.19546 0.173180 -0.07966 0.013836 -0.003374
## 36 0.217794 0.35991 -0.002031 -0.01349 -0.044245 -0.008067
## 37 0.530344 0.16473 -0.072752 0.08482 -0.179419 0.092896
## 38 0.386837 0.15010 0.163132 -0.04098 0.156511 -0.096270
## 39 0.454369 0.32809 0.158876 0.05545 0.229962 0.159861
## 40 0.370033 0.18849 0.150137 -0.01702 0.220776 -0.060391
## 41 0.733763 0.09891 0.543673 -0.25807 -0.215391 -0.102342
## 42 0.751397 0.28756 -0.018136 0.04335 -0.448897 -0.150765
## 43 0.260255 0.27344 0.283415 -0.15403 0.134286 0.053973
## 44 0.626689 0.03673 0.109380 0.08025 0.171751 -0.177150
## 45 0.422041 0.66969 -0.305212 -0.28421 0.194072 -0.040262
## 46 -0.308450 -0.38097 -0.156424 -0.03333 0.027181 -0.080304
## 47 -0.090387 -0.08771 -0.051645 -0.04502 0.049220 -0.105366
## 48 0.243109 0.17544 0.055587 0.16297 0.129623 -0.029377
## 49 -0.098095 -0.03125 -0.176481 -0.08163 -0.086694 0.113537
## 50 -0.123741 -0.28603 -0.028502 0.04567 -0.089356 0.096000
## 51 -0.220621 -0.11869 0.207751 0.06654 -0.025200 0.046210
## 52 0.447317 -0.04547 0.241645 -0.09827 -0.339366 0.198683
## 53 0.154271 -0.24656 0.021007 0.13312 0.174027 0.094545
## 54 0.139250 -0.34166 0.111607 0.17523 0.117702 0.191989
summary(pca2,scaling=2)
##
## Call:
## rda(X = wc, scale = TRUE)
##
## Partitioning of correlations:
## Inertia Proportion
## Total 18 1
## Unconstrained 18 1
##
## Eigenvalues, and their contribution to the correlations
##
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Eigenvalue 8.0611 3.4761 1.50819 1.22521 0.71533 0.65066 0.61984
## Proportion Explained 0.4478 0.1931 0.08379 0.06807 0.03974 0.03615 0.03444
## Cumulative Proportion 0.4478 0.6410 0.72474 0.79281 0.83255 0.86870 0.90314
## PC8 PC9 PC10 PC11 PC12 PC13
## Eigenvalue 0.43868 0.4085 0.28913 0.166975 0.118712 0.107401
## Proportion Explained 0.02437 0.0227 0.01606 0.009276 0.006595 0.005967
## Cumulative Proportion 0.92751 0.9502 0.96627 0.975542 0.982137 0.988104
## PC14 PC15 PC16 PC17 PC18
## Eigenvalue 0.087748 0.063765 0.04590 0.0107740 0.0059461
## Proportion Explained 0.004875 0.003543 0.00255 0.0005986 0.0003303
## Cumulative Proportion 0.992979 0.996521 0.99907 0.9996697 1.0000000
##
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores: 5.531195
##
##
## Species scores
##
## PC1 PC2 PC3 PC4 PC5 PC6
## cond -0.99702 0.34972 -0.45496 -0.04411 0.13442 0.08488
## pH 0.17684 0.29544 0.57043 -0.85920 -0.54326 -0.30724
## turb -0.52396 -0.94668 -0.34857 -0.47256 -0.03982 0.25901
## Alk -0.63291 0.85155 -0.31425 0.13417 0.12058 -0.12839
## TSS -0.53705 -0.77957 -0.43743 -0.64323 -0.04180 0.28207
## PO4 -0.05355 -0.59396 0.73584 -0.33539 0.79636 -0.11188
## NH4 -0.77319 0.03783 -0.68069 -0.06619 0.19035 -0.53093
## NO2 -0.78431 -0.58641 -0.15264 -0.08530 -0.10877 -0.62400
## NO3 -0.67655 -0.89920 0.22318 0.46162 -0.18975 -0.01087
## Br -1.20613 -0.13602 0.08215 0.06930 0.01147 0.28837
## Cl -1.08187 -0.16509 0.49846 0.21967 0.03718 -0.12252
## Fl -1.11621 -0.11372 0.18254 -0.05032 0.14197 -0.03546
## SO4 -1.05771 0.24288 0.40207 0.23188 -0.21474 0.01286
## Na -1.14870 0.17217 0.13648 0.05892 -0.21020 0.18551
## K -1.03824 0.48474 0.25134 -0.15451 0.03470 0.09851
## Ca -0.95603 0.73948 -0.06107 -0.22861 0.11002 0.06037
## Mg -0.99397 0.64159 0.05003 -0.24907 0.04694 0.06880
## TDN -0.86580 -0.78875 -0.05764 0.31464 -0.19754 -0.07204
##
##
## Site scores (weighted sums of species scores)
##
## PC1 PC2 PC3 PC4 PC5 PC6
## 1 -1.283073 1.46362 0.329969 1.17010 0.42054 0.64811
## 2 -1.034856 1.29806 0.047297 -1.40897 0.23982 1.05835
## 3 -0.882710 1.69037 -0.205471 0.53435 -0.97579 -0.24031
## 4 -0.994400 0.94315 0.505607 0.14215 -0.25215 -0.60337
## 5 -2.431354 0.65908 -1.898250 -0.84073 -0.96461 -1.22401
## 7 0.625497 0.59533 0.335832 0.26999 0.46695 -1.53700
## 8 1.479591 0.71474 -2.670917 -1.30598 -0.33714 0.79142
## 9 -0.445864 0.46757 -0.662112 2.69914 -0.97712 0.59770
## 10 -0.761641 0.42997 0.078779 -1.25501 1.05851 0.23628
## 11 0.236561 0.72111 -0.598763 0.65145 1.19091 0.35206
## 12 1.141965 0.47600 -0.093490 0.25066 -0.74183 -0.50609
## 13 -0.266793 -0.81652 -0.519182 -0.08502 0.98419 0.15946
## 14 1.856240 -1.27798 -2.134725 0.31427 0.53622 -1.01871
## 15 -0.551353 -1.32214 -0.026774 -0.19529 -0.31291 0.30059
## 16 -1.000529 -0.09745 -0.165024 0.82015 0.76709 -1.46104
## 17 -1.137819 -0.55812 0.102472 0.12211 0.28418 -0.34966
## 18 -0.635730 -0.10995 -0.083433 0.08852 0.08615 1.19206
## 19 -0.350048 -0.61812 0.238228 -0.74534 -0.27547 0.09870
## 20 0.043308 -0.44619 -0.616293 0.21443 -1.00207 1.03184
## 21 -0.506526 -0.74355 0.520934 -0.32837 -0.52971 -0.12075
## 22 -0.191623 -0.73919 0.679868 -0.07152 -0.12217 2.02785
## 23 -0.542921 -0.42120 0.205271 -0.34908 0.08852 -0.25500
## 24 -0.891549 -1.03600 0.087247 -0.06393 0.27935 -0.67049
## 25 -0.046249 -0.83270 0.886679 -1.66658 -1.29329 -1.16661
## 26 0.287167 -1.00938 0.075905 -0.38458 0.26442 0.03373
## 27 0.062323 -0.58078 -0.420579 0.55599 -0.74345 0.20414
## 28 0.114344 -1.02675 -0.128087 -0.11522 0.48227 -0.18664
## 29 0.131909 -0.90355 0.092727 0.14660 0.57868 0.27300
## 30 -0.242136 -0.88933 -0.900465 0.49281 -0.20915 0.35172
## 31 0.598040 0.66619 0.632611 0.63693 -0.11075 1.10934
## 32 0.291300 0.63471 0.038214 0.41094 0.04070 -0.21870
## 33 0.143544 -0.10039 0.902594 1.70768 -0.31291 -1.76226
## 34 -0.123959 0.49543 0.498420 -1.42250 0.43705 -0.16622
## 35 -0.007017 -0.44478 0.598281 -0.30532 0.06941 -0.01775
## 36 0.325450 0.81900 -0.007016 -0.05172 -0.22195 -0.04243
## 37 0.792494 0.37487 -0.251334 0.32512 -0.90002 0.48860
## 38 0.578051 0.34156 0.563571 -0.15707 0.78511 -0.50635
## 39 0.678964 0.74658 0.548865 0.21253 1.15356 0.84082
## 40 0.552941 0.42893 0.518675 -0.06526 1.10748 -0.31764
## 41 1.096463 0.22508 1.878217 -0.98915 -1.08047 -0.53829
## 42 1.122814 0.65436 -0.062654 0.16617 -2.25180 -0.79297
## 43 0.388900 0.62223 0.979109 -0.59038 0.67362 0.28388
## 44 0.936463 0.08358 0.377874 0.30759 0.86156 -0.93175
## 45 0.630656 1.52392 -1.054410 -1.08937 0.97352 -0.21177
## 46 -0.460918 -0.86694 -0.540394 -0.12777 0.13635 -0.42237
## 47 -0.135065 -0.19959 -0.178417 -0.17257 0.24690 -0.55419
## 48 0.363278 0.39923 0.192034 0.62466 0.65023 -0.15452
## 49 -0.146583 -0.07110 -0.609688 -0.31289 -0.43489 0.59717
## 50 -0.184906 -0.65088 -0.098466 0.17505 -0.44824 0.50493
## 51 -0.329674 -0.27009 0.717715 0.25504 -0.12641 0.24305
## 52 0.668426 -0.10346 0.834806 -0.37667 -1.70236 1.04501
## 53 0.230527 -0.56106 0.072573 0.51022 0.87297 0.49728
## 54 0.208081 -0.77747 0.385568 0.67163 0.59043 1.00980
layout(matrix(1:2, nrow=1))
biplot(pca2,scaling=1)
biplot(pca2,scaling=2)# note different scaling factors, but solution remains same
##############################
# some follow-up suggestions #
# test PCA-axes for effect of landuse or stream size (as log(Q)) using ANOVA or ANCOVA
# correlate PCA-axes with other potential "controlling" variables (e.g. canopy cover) to give "meta-dimensions" more meaning
# useful function envfit() to relate additional variables to the ordination spaceThe classical ordination methods always target dimension reduction
Two involved matrices: one dependent, one independent.
(Note: For correlation of two matrices see CCorA (Canonical correlation analysis) \(\neq\) CCA.)
Redundancy: The proportion of total variance of in the response variables that can be explained linear combinations of predictors.
Two steps:
The response variables are constrained to be linear combinations of the predictors first! The PCA can only “ordinate” variation of the responses that is relatable to predictors.
Significance tests for the overall model, for the various RDA-axes and for the individual predictors are available (permutation-based).